package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Djgl;
import com.ruoyi.system.service.IDjglService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 冻精管理Controller
 * 
 * @author ruoyi
 * @date 2025-02-15
 */
@RestController
@RequestMapping("/system/djgl")
public class DjglController extends BaseController
{
    @Autowired
    private IDjglService djglService;

    /**
     * 查询冻精管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:djgl:list')")
    @GetMapping("/list")
    public TableDataInfo list(Djgl djgl)
    {
        startPage();
        List<Djgl> list = djglService.selectDjglList(djgl);
        return getDataTable(list);
    }

    /**
     * 导出冻精管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:djgl:export')")
    @Log(title = "冻精管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Djgl djgl)
    {
        List<Djgl> list = djglService.selectDjglList(djgl);
        ExcelUtil<Djgl> util = new ExcelUtil<Djgl>(Djgl.class);
        util.exportExcel(response, list, "冻精管理数据");
    }

    /**
     * 获取冻精管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:djgl:query')")
    @GetMapping(value = "/{标准号}")
    public AjaxResult getInfo(@PathVariable("标准号") String 标准号)
    {
        return success(djglService.selectDjglBy标准号(标准号));
    }

    /**
     * 新增冻精管理
     */
    @PreAuthorize("@ss.hasPermi('system:djgl:add')")
    @Log(title = "冻精管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Djgl djgl)
    {
        return toAjax(djglService.insertDjgl(djgl));
    }

    /**
     * 修改冻精管理
     */
    @PreAuthorize("@ss.hasPermi('system:djgl:edit')")
    @Log(title = "冻精管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Djgl djgl)
    {
        return toAjax(djglService.updateDjgl(djgl));
    }

    /**
     * 删除冻精管理
     */
    @PreAuthorize("@ss.hasPermi('system:djgl:remove')")
    @Log(title = "冻精管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{标准号s}")
    public AjaxResult remove(@PathVariable String[] 标准号s)
    {
        return toAjax(djglService.deleteDjglBy标准号s(标准号s));
    }
}
